using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace S.O.Domain.Medical
{
    /// <summary>
    /// 处方药品明细实体类
    /// 存储处方中每个药品的详细信息
    /// </summary>
    [Table("PrescriptionMedicines")]
    public class PrescriptionMedicineModel : BaseEntity
    {
        /// <summary>
        /// 处方ID（外键）
        /// 关联到Prescription表
        /// </summary>
        [Required]
        [StringLength(20)]
        [Column("PrescriptionId")]
        public string PrescriptionId { get; set; } = string.Empty;

        /// <summary>
        /// 药品名称
        /// </summary>
        [Required]
        [StringLength(100)]
        [Column("MedicineName")]
        public string MedicineName { get; set; } = string.Empty;

        /// <summary>
        /// 药品规格
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Specification")]
        public string Specification { get; set; } = string.Empty;

        /// <summary>
        /// 剂量
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Dosage")]
        public string Dosage { get; set; } = string.Empty;

        /// <summary>
        /// 频次
        /// 如：每日一次、每日两次等
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Frequency")]
        public string Frequency { get; set; } = string.Empty;

        /// <summary>
        /// 疗程
        /// 如：7天、14天等
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Duration")]
        public string Duration { get; set; } = string.Empty;

        /// <summary>
        /// 用法
        /// 如：口服、外用、注射等
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Usage")]
        public string Usage { get; set; } = string.Empty;

        /// <summary>
        /// 备注
        /// 对该药品的特殊说明
        /// </summary>
        [StringLength(200)]
        [Column("Remark")]
        public string Remark { get; set; } = string.Empty;

        /// <summary>
        /// 数量
        /// 药品的开具数量
        /// </summary>
        [Required]
        [Column("Quantity")]
        public int Quantity { get; set; }

        /// <summary>
        /// 单价
        /// 药品的单位价格
        /// </summary>
        [Required]
        [Column("UnitPrice")]
        public decimal UnitPrice { get; set; }

        /// <summary>
        /// 总金额
        /// 该药品的总费用（数量 × 单价）
        /// </summary>
        [Required]
        [Column("Amount")]
        public decimal Amount { get; set; }

        /// <summary>
        /// 是否已付费
        /// true-已付费，false-未付费
        /// </summary>
        [Required]
        [Column("IsPaid")]
        public bool IsPaid { get; set; } = false;

        /// <summary>
        /// 排序号
        /// 用于控制药品在处方中的显示顺序
        /// </summary>
        [Column("SortOrder")]
        public int SortOrder { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Required]
        [Column("CreateTime")]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        [Required]
        [Column("UpdateTime")]
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否启用
        /// true-启用，false-禁用
        /// </summary>
        [Required]
        [Column("IsEnable")]
        public bool IsEnable { get; set; } = true;

        /// <summary>
        /// 导航属性：关联的处方信息
        /// </summary>
        [ForeignKey("PrescriptionId")]
        public virtual PrescriptionModel? Prescription { get; set; }
    }
}